layui.define([ 'form', 'laydate', 'table' ], function(exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var itserviceServicesTable = null;
    var view ={
        init:function(){
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function(){
                Lib.doSearchForm($("#searchForm"),itserviceServicesTable)
            }
        },
        initTable:function(){
            itserviceServicesTable = table.render({
                elem : '#itserviceServicesTable',
                height : Lib.getTableHeight(1),
                cellMinWidth: 100,
                method : 'post',
                url : Common.ctxPath + '/itss/itserviceServices/list.json' // 数据接口
                ,page : Lib.tablePage, // 开启分页
                //,limit : 10,
                cols : [ [ // 表头
                    {
                        type : 'checkbox',
                        fixed:'left',
                    },
                {

                    field : 'reqid', 
                        title : 'reqid',
                    fixed:'left',
                        width : 60,
                },
                {

                    field : 'reqotherid', 
                        title : 'reqotherid',
                },
                {

                    field : 'reqweekid', 
                        title : '周',
                },
                {

                    field : 'reqby', 
                        title : '需求人',
                },
                {

                    field : 'reqdt', 
                        title : '需求日期',
                },
                {

                    field : 'reqsystem', 
                        title : '系统',
                },
                {

                    field : 'reqmodule', 
                        title : '模块',
                },
                {

                    field : 'reqissus', 
                        title : '功能',
                },
                {

                    field : 'level', 
                        title : '优先级',
                },
                {

                    field : 'status', 
                        title : '状态',
                },
                {

                    field : 'reqtitle', 
                        title : '标题',
                },
                {

                    field : 'reqdescription', 
                        title : '内容描述',
                },
                {

                    field : 'enable', 
                        title : 'enable',
                },
                {

                    field : 'createby', 
                        title : '创建人',
                },
                {

                    field : 'createdt', 
                        title : '创建时间',
                },
                {

                    field : 'finishby', 
                        title : '完成人',
                },
                {

                    field : 'finishdt', 
                        title : '完成时间',
                },
                {

                    field : 'platform', 
                        title : 'platform',
                },

        ] ]

        });

            table.on('checkbox(itserviceServicesTable)', function(obj){
                var itserviceServices = obj.data;
                if(obj.checked){
                    //按钮逻辑Lib.buttonEnable()
                }else{

                }
            })
        },

        initSearchForm:function(){
            Lib.initSearchForm( $("#searchForm"),itserviceServicesTable,form);
        },
        initToolBar:function(){
            toolbar = {
                add : function() { // 获取选中数据
                    var url = "/itss/itserviceServices/add.do";
                    Common.openDlg(url,"ItserviceServices管理>新增");
                },
                edit : function() { // 获取选中数目
                    var data = Common.getOneFromTable(table,"itserviceServicesTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/itss/itserviceServices/edit.do?reqid="+data.reqid;
                    Common.openDlg(url,"ItserviceServices管理>"+data.reqid+">编辑");
                },
                del : function() {
                    layui.use(['del'], function(){
                        var delView = layui.del;
                        delView.delBatch();
                    });
                }
        };
            $('.ext-toolbar').on('click', function() {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    };
    exports('index',view);

});